<!--  -->
<template>
  <div style="padding: 15px 30px">
    <div v-if="m_information">
      <template v-for="(item, i) in m_information">
        <el-descriptions v-if="item.rootPrimaryKey" title="系统" :key="i" class="margin-top" :column="2" size="small">
          <el-descriptions-item label="系统名称">{{ item.systemName }}</el-descriptions-item>
          <el-descriptions-item label="设计单位">{{ item.designUnit }}</el-descriptions-item>
          <el-descriptions-item label="系统集成单位">{{ item.integratedUnit }}</el-descriptions-item>
          <el-descriptions-item label="附件" labelStyle="width:50px;">
            <div>
              <span style="color: #409eff; cursor: pointer" v-for="(m, index) in item.businessAttachment" :key="index" class="btntext" type="text" @click="DownClick(m)">{{ m.fileTitle }}<span style="color: #333" v-if="index + 1 !== item.businessAttachment.length"> ， </span></span>
            </div>
          </el-descriptions-item>
        </el-descriptions>
      </template>
    </div>
    <template v-for="(item, i) in m_ReviewInfor.rows">
      <el-descriptions :key="i" class="margin-top-20" title="子系统" :column="2" size="small">
        <el-descriptions-item label="系统名称">{{ item.systemName }}</el-descriptions-item>
        <el-descriptions-item label="质保到期日">{{ m_dayjs(item.warrantyDate).format('YYYY-MM-DD') }}</el-descriptions-item>
        <el-descriptions-item label="设备名称">
          <template v-if="item.pocDeviceInfoList">
            <div v-for="(dev, j) in item.pocDeviceInfoList" :key="j">
              {{ dev.deviceName }}
            </div>
          </template>
        </el-descriptions-item>
      </el-descriptions>
      <el-divider :key="i"></el-divider>
    </template>
    <div class="t-right padding-top-15">
      <!-- <el-button v-if="$route.query.IsUpcoming" type="primary" size="mini">审批通过</el-button> -->
      <el-button v-if="!$route.query.taskId" type="primary" size="mini" @click="summitAudit">提 审</el-button>
    </div>
  </div>
</template>
<script>
import dayjs from 'dayjs';
import equipmentManageApi from '../../../api/EquipmentManage';
import projectInfoApi from '../../../api/projectInfo';
import { requestTips, askDialog } from '@js/utils';
export default {
  components: {},
  data() {
    return {
      m_dayjs: dayjs,
      //提审信息
      m_ReviewInfor: {
        IsAdd: true,
        vsb: false,
        form: {},
        rows: [],
      },
      m_information: null,
      projectKey:this.$route.query.projectKey || localStorage.getItem("projectKey")
    };
  },

  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {
    // m_Data: {
    //   immediate: true,
    //   deep: true,
    //   handler(val) {},
    // },
  },
  //接收参数
  props: {
    //m_Data: {
    //type: String,
    //default: '',
    //},
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    this.GetReviewInforData();
  },
  //方法集合
  methods: {
    summitAudit() {
      if (this.m_ReviewInfor.rows.length == 0) {
        this.$message.warning('请添加子系统');
        return;
      }
      askDialog('确认提审?', async () => {
        projectInfoApi
          .summitAudit({
            workType: 5,
            projectKey: this.projectKey,
            workId: this.$route.query.workId,
            // remark: this.m_Approve.form.remark,
            // businessAttachmentParam: this.m_Approve.form.businessAttachmentParam,
          })
          .then(res => {
            if (res.success) {
              this.$message.success(res.message);
              setTimeout(()=>{
                window.close()
              },1000)
            } else this.$message.warning(res.message);
          });
      });
    },
    //查询提审信息
    GetReviewInforData() {
      equipmentManageApi.proclist({ primaryKeys: [this.$route.query.primaryKeys] }).then(res => {
        if (res && res.rows.length > 0) {
          this.m_information = res.rows;
        }
      });
      equipmentManageApi.Reviewlist({ workId: this.$route.query.workId }).then(res => {
        let ok = [];
        res.rows.forEach(item => {
          if (item.parentPrimaryKey) {
            ok.push(item);
          }
        });
        this.m_ReviewInfor.rows = ok;
      });
    },
    DownClick(item) {
      window.open(item.fileUrl);
    },
  },
};
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>